import * as types from '@/store/mutations-types'

const mutations = {
  [types.SET_LOGINED](state){
    state.logined = true
  },
  [types.REMOVE_LOGINED](state){
    state.logined = false
    state.user = false
  },
  [types.SET_USER](state,payload){
    state.user = payload
  },
  [types.SET_USER_PERMISSIONS](state, permissions){
    let _permissions = []
    // TODO 权限的处理
    _permissions =[...permissions]
    // for (let i = 0; i < permissions.length; i++) {
    //   for (const key in permissions[i]) {
    //     // console.log(i, state.user.permissions[i][key])
    //     for (let j = 0; j < permissions[i][key].length; j++) {
    //       _permissions.push(permissions[i][key][j].permission)
    //     }
    //   }
    // }
    state.permissions = _permissions
  },
  [types.SET_USER_MENUS](state, menus){
    state.menus = menus
  },



}
export default mutations
